#include<stdio.h>
#include<signal.h>
#include<unistd.h>

struct sigaction oldact;
void func(int sig){
    printf("signal is %d\n", sig);
    //将2号信号的处理方式恢复为原来的方式
    sigaction(2, &oldact, NULL);
}
int main(){
//    signal(2,func);
    struct sigaction act;
    act.sa_handler = func;
    //将sa_mask的内存修改为全0.防止后续误导进程收到了某些信号
    sigemptyset(&act.sa_mask);
    sigaction(2, &act, &oldact);
    while(1){
        sleep(1);
    }
    return 0;
}
